﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AccountForm.ascx.cs" Inherits="AcademicPlanner.Presentation.Views.Shared.AccountForm" %>
<%@ Import Namespace="AcademicPlanner.Framework.Libraries.Mvc" %>
<%@ Import Namespace="AcademicPlanner.Framework.Helpers" %>
<%@ Import Namespace="AcademicPlanner.Presentation" %>
<%@ Import Namespace="AcademicPlanner.Presentation.Views.Shared" %>
<%@ Import Namespace="AcademicPlanner.Domain.Components" %>
<%@ Import Namespace="AcademicPlanner.Domain.Models" %>

<% if (!Model.IsSub)
   { %>
		<div class="form yui-skin-sam">
		<% Begin(); %>
<% } %>

<% if (!string.IsNullOrEmpty(Title))
   { %>
		<fieldset><legend><%= Html.Encode(Title) %></legend>
<% } %>

<% if (!Model.IsSub)
   { %>
		<%= WidgetHelper.FormErrorsBlock("", Model.Id + "Errors", "hidden") %>
<% } %>



<% if (Model.Scenario.Equals(AccountFormScenario.LOGIN))
   {
	%>
	<div class="rows-wrapper">
		<div class="row">
			<div class="cell label">
				<%= Html.Label(GetFieldName("Name", "User"), 
								Html.Encode(Tr(Labels.Get("Name", "User"))), true)%>
			</div>
			<div class="cell field">
				<%= Html.TextField(GetFieldName("Name", "User"), UserNameValue)%>
			</div>
		</div>
		<div class="row">
			<div class="cell label">
				<%= Html.Label(GetFieldName("Password", "User"), 
								Html.Encode(Tr(Labels.Get("Password", "User"))), true) %>
			</div>
			<div class="cell field">
				<%= Html.PasswordField(GetFieldName("Password", "User"), UserPasswordValue) %>
			</div>
		</div>
		<div class="row">
			<div class="cell label">
				&nbsp;
			</div>
			<div class="cell field">
				<%= Html.CheckBox(GetFieldName("RememberMe", "User"), RememberMeValue) %>
				&nbsp;
				<%= Html.Label(GetFieldName("RememberMe", "User"), Html.Encode(Tr("Remember Me"))) %>
			</div>
		</div>
	</div>
		
<% }
   else if (Model.Scenario.Equals(AccountFormScenario.NEW))
   {
	%>
		<div class="rows-wrapper">
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Name", "User"), 
									Html.Encode(Tr(Labels.Get("Name", "User"))), true)%>
				</div>
				<div class="cell field">
					<%= Html.TextField(GetFieldName("Name", "User"), UserNameValue)%>
				</div>
				<div class="cell">
					<span class="hint"><%= Html.Encode(string.Format(Tr("maximum of {0} characters, cannot start with " +
					                   						"\"{1}\", will be lowercased and spaces replaced with \"_\""),
					                   					User.NAME_MAX_LENGTH,			 
					                   					AuthMngr.SYS_USER_NAMES_PREFIX)) %></span>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Password", "User"),
									Html.Encode(Tr(Labels.Get("Password", "User"))), true) %>
				</div>
				<div class="cell field">
					<%= Html.PasswordField(GetFieldName("Password", "User"), UserPasswordValue) %>
				</div>
				<div class="cell">
					<span class="hint"><%= Html.Encode(string.Format(Tr("between {0} and {1} characters, alphanumerics and " +
															"\"_&*$#@!?\" only"), 
					                   					User.PASSWORD_MIN_LENGTH,
					                   					User.PASSWORD_MAX_LENGTH)) %></span>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("RepeatedPassword", "User"), 
									Html.Encode(Tr(Labels.Get("RepeatedPassword", "User"))), true) %>
				</div>
				<div class="cell field">
					<%= Html.PasswordField(GetFieldName("RepeatedPassword", "User"), UserPasswordValue) %>
				</div>
				<div class="cell">
					&nbsp;
				</div>
			</div>
		</div>
<% }
   else if (Model.Scenario.Equals(AccountFormScenario.EDIT))
   {
	%>
		<div class="rows-wrapper">
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Name", "User"),
									Html.Encode(Tr(Labels.Get("Name", "User")))) %>
				</div>
				<div class="cell field">
					<i><%= Html.Encode(UserNameValue) %></i>
				</div>
				<div class="cell">
					<%= Html.NBS() %>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Password", "User"), 
									Html.Encode(Tr(Labels.Get("Password", "User"))), true) %>
				</div>
				<div class="cell field">
					<%= Html.PasswordField(GetFieldName("Password", "User"), UserPasswordValue) %>
				</div>
				<div class="cell">
					<span class="hint"><%= Html.Encode(string.Format(Tr("between {0} and {1} characters, alphanumerics and " +
															"\"_&*$#@!?\" only"), 
					                   					User.PASSWORD_MIN_LENGTH,
					                   					User.PASSWORD_MAX_LENGTH)) %></span>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("RepeatedPassword", "User"), 
									Html.Encode(Tr(Labels.Get("RepeatedPassword", "User"))), true) %>
				</div>
				<div class="cell field">
					<%= Html.PasswordField(GetFieldName("RepeatedPassword", "User"), UserPasswordValue) %>
				</div>
				<div class="cell">
					&nbsp;
				</div>
			</div>
		</div>
<% } %>


<% if (!Model.IsSub)
   { %>
		<div class="rows-wrapper action">
			<div class="row">
				<div class="cell label">
					&nbsp;
				</div>
				<div class="cell">
					<%= Html.SubmitButton("submitForm", Html.Encode(SubmitButtonValue), "")%>
				</div>
			</div>
		</div>
<% } %>


<% if (!string.IsNullOrEmpty(Title))
   { %>
		</fieldset>
<% } %>


<% if (!Model.IsSub)
   { %>
		<% End(); %>
		</div>
<% } %>